## Nuclear Latency

rm(list = ls())


library(dplyr)
library(ggplot2)
library(rstudioapi)

setwd(dirname(getActiveDocumentContext()$path))

sink("DescriptiveStats_log.txt")


start_year <- 1955
end_year <- 2010


latency <- read.csv("nu_infrastructure_submission.csv")
latency <- dplyr::select(latency, ccode, year, Nu_means)
latency <- subset(latency, start_year <= latency$year & latency$year <= end_year)

Japan <- subset(latency, latency$ccode == 740)
SouthKorea <- subset(latency, latency$ccode == 732)


# Figure 1
y1 <- c(Japan$Nu_means)
y2 <- c(SouthKorea$Nu_means)
x <- c(SouthKorea$year)
df <- data.frame(x = rep(x,1), y = c(y1, y2), Legend = c(rep("South Korea", 56), rep("Japan", 56)))
ggplot(df, aes(x=x, y=y, linetype=Legend)) + 
  geom_line(size = 1.5) + 
  xlab("Year") + 
  ylab("Mean Nuclear Latency Level") +
  scale_linetype_manual(values = c(1, 2),
                        labels = c("Competitor", "US")) +
  theme(legend.position="none",
        legend.key.size = unit(2, 'cm'),
        legend.key.width = unit(2, 'cm'),
        axis.text=element_text(size=16,face="bold"),
        axis.title=element_text(size=20,face="bold"),
        legend.title=element_blank()) +
  annotate("text",
           x = 2000,
           y = 1.8,
           label = "Japan",
           size = 7,
           col="black") +
  annotate("text",
           x = 1975,
           y = 0.5,
           label = "South Korea",
           size = 7,
           col="black")


sink()